package test.library.behavior;

import test.library.Book;
import test.library.BookList;

import java.util.Scanner;

public class FindBook implements IBehavior{
    public void work(BookList bookList){
        System.out.println("搜索书籍");
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入书名:");
        String name =scanner.next();
        for(int i = 0;i < bookList.getQuantity();i++){
            Book book = bookList.getBook(i);
            if(book.getName().equals(name)){
                System.out.println(bookList.getBook(i));
                System.out.println("书籍已查找到!");
                return;
            }
        }
        System.out.println("书籍未查找到");
    }
}
